package net.sx.minemodule.mvp.bean;

import android.os.Parcel;
import android.os.Parcelable;

import com.kedll.library.adapter.MultiTypeAdapter;
import com.kedll.library.mvp.BaseItem;
import com.kedll.library.mvp.BaseModel;

import net.sx.minemodule.mvp.item.GoodsItems;

import java.util.List;

/**
 * @author 11470
 */
public class GoodsBean extends BaseModel<BaseItem> implements Parcelable {
    /**
     * id : 1
     * productId : 26
     * pic : http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180607/5ac1bf58Ndefaac16.jpg
     * productName : 华为 HUAWEI P20
     * num : 1
     * salePrice : 37
     * attrs : [{"name":"测试","value":"16GB"}]
     */

    private int id;
    private int productId;
    private String pic;
    private String productName;
    private int num;
    private int salePrice;
    private String promotionName;
    private boolean distributionType;
    private List<AttrsBean> attrs;

    public GoodsBean() {
    }


    protected GoodsBean(Parcel in) {
        id = in.readInt();
        productId = in.readInt();
        pic = in.readString();
        productName = in.readString();
        num = in.readInt();
        salePrice = in.readInt();
        promotionName = in.readString();
        distributionType = in.readByte() != 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(id);
        dest.writeInt(productId);
        dest.writeString(pic);
        dest.writeString(productName);
        dest.writeInt(num);
        dest.writeInt(salePrice);
        dest.writeString(promotionName);
        dest.writeByte((byte) (distributionType ? 1 : 0));
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<GoodsBean> CREATOR = new Creator<GoodsBean>() {
        @Override
        public GoodsBean createFromParcel(Parcel in) {
            return new GoodsBean(in);
        }

        @Override
        public GoodsBean[] newArray(int size) {
            return new GoodsBean[size];
        }
    };

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getProductId() {
        return productId;
    }

    public void setProductId(int productId) {
        this.productId = productId;
    }

    public String getPic() {
        return pic;
    }

    public void setPic(String pic) {
        this.pic = pic;
    }

    public String getProductName() {
        return productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }

    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
    }

    public int getSalePrice() {
        return salePrice;
    }

    public void setSalePrice(int salePrice) {
        this.salePrice = salePrice;
    }

    public String getPromotionName() {
        return promotionName;
    }

    public void setPromotionName(String promotionName) {
        this.promotionName = promotionName;
    }

    public boolean isDistributionType() {
        return distributionType;
    }

    public void setDistributionType(boolean distributionType) {
        this.distributionType = distributionType;
    }

    public List<AttrsBean> getAttrs() {
        return attrs;
    }

    public void setAttrs(List<AttrsBean> attrs) {
        this.attrs = attrs;
    }

    @Override
    public GoodsItems createItem(MultiTypeAdapter adapter) {
        return new GoodsItems(this);

    }

    public static class AttrsBean {
        /**
         * name : 测试
         * value : 16GB
         */

        private String name;
        private String value;

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getValue() {
            return value;
        }

        public void setValue(String value) {
            this.value = value;
        }
    }




}
